var loginForm = document.getElementById("login_form");
var loginBtn = document.getElementById("login_btn");
var pw = document.getElementById("pw");
var appkey = 'hesong_1618800008142';

loginBtn.onclick = function () {
  // 获取表单输入的内容
  var uname = loginForm.elements.uname.value;
  var pw = loginForm.elements.pw.value;
  if (uname && pw) {
    ajax({
      url: "https://api.duyiedu.com/api/student/stuLogin",
      type: 'POST',
      params: {
        appkey: appkey,
        account: uname,
        password: pw
      },
      success(value) {
        var Msg = JSON.parse(value);
        if (Msg === "fail") {
          alert("错误信息:" + Msg.msg);
        } else {
          alert(Msg.msg);
          location.href = '../main/index.html?name='+uname
        }
      }
    })
  } else {
    alert("请输入用户名和密码")
  }
}